--- 掎势技能 - 主技能文件
--- 回合技，转换技，己方角色可以视为使用①【过河拆桥】②【顺手牵羊】③【落井下石】。
--- 若此牌目标之一因此变为符合下一个转换项合法目标，重置发动次数。
local jishi = fk.CreateSkill {
  name = "lvshi__jishi",
  tags = {"switch","Turn"},
}

local ls = require "packages/lvshi/utility"
local DIY = require "packages/diy_utility/diy_utility"

-- 初始化转换技状态
jishi:addAcquireEffect(function (self, player, is_start)
  DIY.setSwitchState(player, jishi.name, 1, 3)
end)

-- 清理转换技状态
jishi:addLoseEffect(function (self, player)
  DIY.removeSwitchSkill(player, jishi.name)
end)

-- 在出牌阶段开始时，为友方角色添加viewas技能
jishi:addEffect(fk.EventPhaseStart, {
  is_delay_effect = true,
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(jishi.name) and target.phase == Player.Play and ls.isFriend(player, target)
  end,
  on_use = function(self, event, target, player, data)
    -- 添加viewas技能给友方角色
    player.room:handleAddLoseSkills(target, "lvshi__jishi_viewas&")
    player.room:setPlayerMark(target, "jishi_from", player.id)--暂时不考虑多个来源
  end
})

Fk:loadTranslationTable{
  ["lvshi__jishi"] = "掎势",
  ["#lvshi__jishi"] = "掎势",
  ["$lvshi__jishi"] = "",
  [":lvshi__jishi"] = "回合技，转换技，己方角色的出牌阶段，可视为使用①【过河拆桥】②【顺手牵羊】③【落井下石】。若此牌目标之一因此变为符合下一个转换项合法目标，重置发动次数。",
  ["lvshi__jishi_viewas"] = "掎势",
  ["#lvshi__jishi-viewas"] = "掎势：选择一张牌当【%src】使用",
  ["~lvshi__jishi"] = "",
  ["~lvshi__jishi_viewas"] = "",
}

return jishi